<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品审核</title>
    <script src="/jquery/jquery-3.2.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <style>
        *{
            background-color:rgb(243,243,243);
        }
        .box{
            padding: 10px 50px 0px 50px;
        }
        .layui-layedit{
            margin-left: 76px;
        }
        .buttonBox{
            margin-left: 640px;
            margin-top: 200px;
        }
        form p{
            margin-top: 30px;
        }
        #demo_editor{
            margin-left: -34px;
            margin-top: -14px;
        }
    </style>
</head>
<body>
    <div id="app" class="box">
        <form class="layui-form" lay-filter="audit">
            <p id="productName"></p>
            <p id="check">
                用户审核：
                <input name="result" type="radio" checked lay-filter="check" title="审核通过" value="1"/>
                <input name="result" type="radio" lay-filter="check" title="审核不通过" value="3" />
            </p>
            <p>
                审核备注：
                <div class="layui-form-text">
                    <div class="layui-input-block" >
                        <textarea name="remarks" placeholder="请输入内容" lay-verify="content"  id="demo_editor" class="layui-textarea" ></textarea>
                    </div>
                </div>
            </p>
            <div class="buttonBox">
                <button class="layui-btn layui-btn-normal layui-btn-sm" type="submit" style="width: 60px;height: 30px;" onclick="queding()">确定</button>
                <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" style="width: 60px;height: 30px;" onclick="quxiao()">关闭</button>
            </div>
        </form>
    </div>

    <input name="courseId" id="courseId" type="hidden" />
    <input name="JsApplyId" id="JsApplyId" type="hidden" />
</body>
<script>
    layui.use(['jquery','layer','form'],function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        var type=1;
        form.on("radio(check)",function (data) {
            if (data.value == 1){
                type = 1;
            }else if (data.value == 3){
                type = 3;
            }
        });

        queding=function queding(){
            var user=JSON.parse(localStorage.getItem("user"))
            var param={
                'courseId':$('#courseId').val(),
                'implementId':user.data.userId,
                'implementDate':getTime(),
                'result':type,
                'remarks':$('#demo_editor').val(),
                'type':4,
            }
            $.ajax({
                url: '/JsApplyRecord/addCourseRecord',
                data: param,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            })

            var params={
                'result':type,
                'id':$('#JsApplyId').val(),
            }
            $.ajax({
                url: '/JsApplyRecord/updateJsApplyRecordResult',
                data: params,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            })

            var data={
                'examineType':4,
                'type':type,
                'userId':user.data.userId,
                'createDate':getTime(),
                'remark':$('#demo_editor').val(),
                'examineId':$('#courseId').val(),
                'userName':user.data.trueName,
            }
            $.ajax({
                url: '/JsApplyRecord/addJsAuditLog',
                data: data,
                type: 'post',
                dataType: 'json',
                success: function (data) {
                }
            })
            var layer = parent.layer;
            layer.close(layer.index);
        }

        quxiao=function quxiao(){
            var layer = parent.layer;
            layer.close(layer.index);
        }

        //现在时间
        function getTime(){
            var date=new Date();
            var year=date.getFullYear();
            var month=date.getMonth()+1;
            var day=date.getDate();
            var hour=date.getHours();
            var minute=date.getMinutes();
            var second=date.getSeconds();
            var dateStr = year+"-"+zeroFilling(month)+"-"+zeroFilling(day)+" "+zeroFilling(hour)+":"+zeroFilling(minute)+":"+zeroFilling(second);
            return dateStr;
        }
        function zeroFilling(data){
            if(data<10){
                data="0"+data;
            }
            return data;
        }

    })
</script>
</html>